<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- try catch -->
    <!-- bind call apply -->

    <script>
        // try catch
        var status = 'sucess';
        try {
            cons.log(status);
            // console.log(status);
        
        } catch(e) {
           status= 'error';
        }

        console.log(status);


        //bind call apply

        var obj1 = {
            name: 'obj1name',
            fn: function () {
                console.log(this.name);
            }
        }
        
        var obj2 = {
            name: 'obj2name',
            fn: function (str) {
                console.log(str);
                console.log(this.name);
            }
        }
        // obj2.fn();
        // obj2.fn.bind(obj1)();
        // obj2.fn();
        // var fun1 = obj2.fn.bind(obj1, 'xiaohong')();
        // fun1();
        // obj2.fn.call(obj1, 'xiaohong', '');
        // obj2.fn.apply(obj1, ['xiaohong','xxx']);
        

        var obj3 = {
            nameObj: 'obj3name',
            fn: function () {
                setTimeout(function () {
                    console.log(this.nameObj);
                }.bind(this),1500);
            }
        }
                
        obj3.fn();

    </script>
</body>
</html>